from django.contrib import admin
from eval_pro.models import *


# Register your models here.

class EvalFeeSumAdmin(admin.ModelAdmin):
    list_filter = ['belong_pro', ]
    list_display = ['belong_pro', 'feedback', 'sum_up']
    list_display_links = ['belong_pro', 'feedback', 'sum_up']
    # list_editable = ['feedback', 'sum_up']

    def formfield_for_dbfield(self, db_field, **kwargs):
        formfield = super(EvalFeeSumAdmin, self).formfield_for_dbfield(db_field, **kwargs)
        if db_field.name == 'feedback' or db_field.name == 'sum_up':
            formfield.widget = forms.Textarea(attrs=formfield.widget.attrs)
        return formfield


class EvalProAdmin(admin.ModelAdmin):
    list_display = ['name', 'belong_sys', 'manager', 'begin', 'estimate', 'end', 'kpi']
    list_display_links = ['belong_sys', 'name']


class EvalDivisionDetailAdmin(admin.ModelAdmin):
    list_display = ['division', 'belong_pro']


class EvalDivProDetailAdmin(admin.ModelAdmin):
    list_display = ['project', 'belong_division']


class EvalDivSubDetailAdmin(admin.ModelAdmin):
    list_display = ['sub_project', 'belong_div', 'begin', 'estimate', 'end', 'usrname', 'kpi']
    # list_display_links = ['sub_project', 'name']


class EvalSchDetailAdmin(admin.ModelAdmin):
    list_display = ['schedule', 'belong_sub_pro']
    list_filter = ['belong_sub_pro']

# admin.site.register(EvalProject)

admin.site.register(EvalSys)
admin.site.register(EvalPro, EvalProAdmin)
admin.site.register(EvalDivisionDetail, EvalDivisionDetailAdmin)
admin.site.register(EvalDivProDetail, EvalDivProDetailAdmin)
admin.site.register(EvalDivSubDetail, EvalDivSubDetailAdmin)
admin.site.register(EvalSchDetail, EvalSchDetailAdmin)
admin.site.register(EvalFeeSum, EvalFeeSumAdmin)
